package com.jason.kotlin.activityresult

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.jason.kotlin.R
import kotlinx.android.synthetic.main.activity_fragment.*

/**
 * Description:FragmentActivity
 *
 * @author chenbaoyang
 * @create 2021/1/14 17:34
 */
class MyFragmentActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fragment)

       backBtn.setOnClickListener {

           val intent = Intent().apply {
               putExtra("result", "Hello，我是回传的数据！")
           }
           setResult(Activity.RESULT_OK, intent)
           finish()
       }

        supportFragmentManager.beginTransaction().apply {
            add(R.id.container, FragmentA.newInstance())
                .commit()
        }
    }
}